#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main()
{
    string s;
    cin >> s;
    unordered_map<char, int> mp1, mp2;
    int ansnum = 0, t;
    for (int i = 0; i < 26; i++)
        cin >> mp1['a' + i]; 
        
    int sz = s.size();
    for (int i = 0; i < sz; i++)
    {
    	mp2[s[i]]++;
    	ansnum += mp1[s[i]];
	}
    for (int i = 0; i < 26; i++)
    {
        cout << mp2['a' + i];
        if (i != sz - 1)
            cout << ' ';
    }
    cout << endl << ansnum;
    return 0;
}
